<template>
  <div class="header-contain">
    <div class="header-left" @click="router.push('/')">
      <img src="" alt="" />
      <div class="text1">{{ store.title }}</div>
    </div>
    <div class="header-right">
      <el-dropdown trigger="click" @command="changeMenu">
        <div class="el-dropdown-link">
          <img src="" alt="" />
          <div class="text1">{{ store.user.name }}</div>
          <el-icon class="el-icon--right">
            <arrow-down />
          </el-icon>
        </div>
        <template #dropdown>
          <el-dropdown-menu>
            <el-dropdown-item command="logout">退 出</el-dropdown-item>
          </el-dropdown-menu>
        </template>
      </el-dropdown>
    </div>
  </div>
  <el-dialog v-model="data.logoutDia" class="logoutDia" :show-close="false">
    <div class="logout-dia-contain">
      <div class="dia-title" @click="closeLogoutDia">
        <el-icon class="el-close"><Close /></el-icon>
      </div>
      <div class="dia-body">
        <div class="dia-img">
          <img src="" alt="" />
        </div>
        <div class="dia-tips">确认要退出登录么？</div>
        <div class="dia-buttons">
          <div class="concelBtn1" @click="closeLogoutDia">取消</div>
          <div class="confirmBtn1" @click="confirmLogoutDia">确定</div>
        </div>
      </div>
    </div>
  </el-dialog>
</template>

<script setup name="version">
import { reactive } from 'vue'
import { useRouter } from 'vue-router'
import { useStore } from '../stores'
const router = useRouter()
const store = useStore()
// 初始化数据
let data = reactive({
  logoutDia: false //退出dia的控制器
})
// 点击下拉菜单
const changeMenu = (command) => {
  if (command == 'logout') {
    data.logoutDia = true
  }
}
const closeLogoutDia = () => {
  data.logoutDia = false
}
const confirmLogoutDia = () => {
  data.logoutDia = false
  localStorage.removeItem('token')
  router.push('/login')
}
</script>

<style lang="less" scoped>
.header-contain {
  width: 100%;
  height: 50px;
  position: sticky;
  top: 0;
  left: 0;
  background: #31bab5;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.header-left {
  height: 100%;
  display: flex;
  align-items: center;
  cursor: pointer;
  img {
    width: 36px;
    height: 36px;
  }
  .text1 {
    font-family: AlibabaPuHuiTi_2_85_Bold;
    font-size: 22px;
    color: #ffffff;
    letter-spacing: 2px;
    line-height: 20px;
    font-weight: 700;
    margin-left: 7px;
  }
}
.el-dropdown-link {
  display: flex;
  align-items: center;
  font-size: 15px;
  color: #ffffff;
  letter-spacing: 0;
  line-height: 15px;
  font-weight: 500;

  img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
  }
  .text1 {
    font-family: AlibabaPuHuiTi_2_65_Medium;
    margin-left: 7px;
  }
  i {
    font-weight: 900;
  }
}
.logout-dia-contain {
  width: 380px;
  height: 284px;
  .dia-title {
    padding: 10px;
    display: flex;
    justify-content: flex-end;
    .el-close {
      width: 30px;
      height: 30px;
      display: flex;
      align-items: center;
      justify-content: center;
      background: #eceded;
      border-radius: 50%;
      color: #000;
      font-size: 20px;
      font-weight: 900;
      cursor: pointer;
    }
  }
  .dia-body {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    .dia-img {
      width: 88px;
      height: 88px;
      background: rgba(49, 186, 181, 0.1);
      padding: 20px 16px 0;
      border-radius: 50%;
      img {
        width: 56px;
        height: 56px;
      }
    }
    .dia-tips {
      font-family: AlibabaPuHuiTi_2_85_Bold;
      font-size: 22px;
      color: #333333;
      letter-spacing: 0;
      text-align: center;
      line-height: 22px;
      font-weight: 700;
      margin: 20px 0 30px;
    }
    .dia-buttons {
      display: flex;
      align-items: center;
      justify-content: center;
      .concelBtn1 {
        margin-right: 12px;
      }
    }
  }
}
</style>
